package com.chixing.ih.module.programmer.mapper;

import com.chixing.ih.common.IhRepository;
import com.chixing.ih.module.programmer.mapper.provider.ImageMapperProvider;
import com.chixing.ih.module.programmer.pojo.ProjectImage;
import com.chixing.ih.module.programmer.pojo.UserImage;
import org.apache.ibatis.annotations.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-28
 * Time: 0:24
 * @version 1.0
 */
@Mapper
public interface ImageMapper extends IhRepository<UserImage> {


    @UpdateProvider(type = ImageMapperProvider.class, method = "updateUserOne")
    int updateUserOne(UserImage image);

    @UpdateProvider(type = ImageMapperProvider.class, method = "updateProjectOne")
    int updateProjectOne(ProjectImage projectImage);

    @SelectProvider(type = ImageMapperProvider.class, method = "getOneByUserId")
    @Results(id = "userImageMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "user_id", property = "userId"),
            @Result(column = "image_url", property = "imageUrl"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "is_deleted", property = "isDeleted"),
            @Result(column = "is_legal", property = "isLegal"),

    })
    UserImage getOneByUserId(long userId);

    @SelectProvider(type = ImageMapperProvider.class, method = "getOneByProjectId")
    @Results(id = "projectImageMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "project_id", property = "projectId"),
            @Result(column = "image_url", property = "imageUrl"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "is_deleted", property = "isDeleted"),
            @Result(column = "is_legal", property = "isLegal"),

    })
   ProjectImage getOneByProjectId(long projectId);


    @InsertProvider(type = ImageMapperProvider.class, method = "insertUserOne")
    int insertUserOne(UserImage image);

    @InsertProvider(type = ImageMapperProvider.class, method = "insertProjectOne")
    int insertProjectOne(ProjectImage projectImage);

}
